package com.hdwx.weike.controllers;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by hdwx on 2016/12/31.
 */
@WebServlet(urlPatterns = "/exit.do")
public class ExitController extends BaseController{
    @Override
    public void todo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession(false);
        String str = req.getParameter("url");
        String url="home.jsp";
        if(str!=null){
            try{
                url=str;
            }catch (Exception e){}
        }
        if(session!=null){
            session.invalidate();
            resp.sendRedirect(url);
        }
    }
}
